package com.qqim.common.entity;

import java.io.Serializable;
import java.util.Objects;

/**
 * 用户实体类
 */
public class User implements Serializable {
    private static final long serialVersionUID = 1L;
    
    /** 用户唯一标识 */
    private String userId;
    
    /** 用户昵称 */
    private String nickname;
    
    /** 用户头像路径 */
    private String avatar;
    
    /** 用户状态：online-在线, offline-离线, away-离开, busy-忙碌 */
    private String status;
    
    /** 登录时间 */
    private long loginTime;
    
    /** 最后活动时间 */
    private long lastActiveTime;
    
    public User() {}
    
    public User(String userId, String nickname) {
        this.userId = userId;
        this.nickname = nickname;
        this.status = "online";
        this.loginTime = System.currentTimeMillis();
        this.lastActiveTime = System.currentTimeMillis();
    }
    
    public String getUserId() {
        return userId;
    }
    
    public void setUserId(String userId) {
        this.userId = userId;
    }
    
    public String getNickname() {
        return nickname;
    }
    
    public void setNickname(String nickname) {
        this.nickname = nickname;
    }
    
    public String getAvatar() {
        return avatar;
    }
    
    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }
    
    public String getStatus() {
        return status;
    }
    
    public void setStatus(String status) {
        this.status = status;
        this.lastActiveTime = System.currentTimeMillis();
    }
    
    public long getLoginTime() {
        return loginTime;
    }
    
    public void setLoginTime(long loginTime) {
        this.loginTime = loginTime;
    }
    
    public long getLastActiveTime() {
        return lastActiveTime;
    }
    
    public void setLastActiveTime(long lastActiveTime) {
        this.lastActiveTime = lastActiveTime;
    }
    
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        User user = (User) o;
        return Objects.equals(userId, user.userId);
    }
    
    @Override
    public int hashCode() {
        return Objects.hash(userId);
    }
    
    @Override
    public String toString() {
        return "User{" +
                "userId='" + userId + '\'' +
                ", nickname='" + nickname + '\'' +
                ", status='" + status + '\'' +
                '}';
    }
} 